<template>
	<view class="uiwu">
		<uiwu-list :loading="more">
			<view class="uiwu-list">
				<view class="uiwu-list-item" v-for="(item,index) in listData" :key="index">
					<view class="time">{{item.add_time}}</view>
					<view class="itiem uiwu-flex-space">
						<text class="title">{{item.title}}</text>
						<text class="tips" :class="item.pm == 0 ? 'active' : ''">{{item.pm == 0 ? '-' : '+'}}{{item.number}}</text>
					</view>
				</view>
			</view>
		</uiwu-list>
	</view>
</template>

<script setup lang="ts">
	import { onLoad , onReachBottom } from '@dcloudio/uni-app';
	import { uiwu } from '../../config/config';
	import { moneylist } from '../../api/api';
	import { ref } from 'vue';
	const listData = ref<Array<object>>([])
	const pageNum = ref<number>(1)
	const more = ref<string>('loading');
	const isLock = ref<boolean>(true)
	const getmoneylist = async (mack:boolean = false) : Promise<any> => {
		if(!mack) pageNum.value = 1
		const { data:{data , total}} = await moneylist({
			page:pageNum.value
		});
		isLock.value = true
		uiwu.setlist({
			isMore:mack,
			listData,
			total,
			listRow:data,
			more,
			pageNum
		})
	}
	/**
	 * 加载更多
	 */
	onReachBottom(()=>{
		if(!isLock.value) return 
		isLock.value = false
		pageNum.value++
		getmoneylist(true)
	})
	onLoad(()=>{
		getmoneylist()
	})
</script>

<style lang="scss">
	page{
		background-color: #F6F6F6;
	}
	.uiwu-list{
		&-item{
			.time{
				font-size: 24rpx;
				font-weight: 400;
				color: #444444;
				line-height: 72rpx;
				padding: 0 24rpx;
			}
			.itiem{
				background-color: #fff;
				padding: 32rpx 24rpx;
				border-bottom: 1rpx solid #E6E6E6;
				&:last-child{
					border-bottom: 0;
				}
				.title{
					font-size: 28rpx;
					font-weight: 800;
					color: #231815;
				}
				.tips{
					font-size: 28rpx;
					font-weight: 500;
					color: #5BB431;
					&.active{
						color: #EF821E;
					}
				}
			}
		}
	}
</style>
